
<!DOCTYPE HTML>
<html lang="" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>Go 语言变量 · GitBook</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        
        
        
    
    <link rel="stylesheet" href="../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="../part7/" />
    
    
    <link rel="prev" href="../part5/" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    Introduction
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../part1/">
            
                <a href="../part1/">
            
                    
                    Go 语言简介
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="../part2/">
            
                <a href="../part2/">
            
                    
                    Go 语言环境安装
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="../part3/">
            
                <a href="../part3/">
            
                    
                    Go 语言结构
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="../part4/">
            
                <a href="../part4/">
            
                    
                    Go 语言基础语法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="../part5/">
            
                <a href="../part5/">
            
                    
                    Go 语言数据类型
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.7" data-path="./">
            
                <a href="./">
            
                    
                    Go 语言变量
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8" data-path="../part7/">
            
                <a href="../part7/">
            
                    
                    Go 语言常量
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9" data-path="../part8/">
            
                <a href="../part8/">
            
                    
                    Go 语言运算符
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10" data-path="../part9/">
            
                <a href="../part9/">
            
                    
                    Go 语言条件语句
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11" data-path="../part10/">
            
                <a href="../part10/">
            
                    
                    Go 语言循环语句
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12" data-path="../part11/">
            
                <a href="../part11/">
            
                    
                    Go 语言函数
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13" data-path="../part12/">
            
                <a href="../part12/">
            
                    
                    Go 语言数组
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.14" data-path="../part13/">
            
                <a href="../part13/">
            
                    
                    Go 语言指针
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.15" data-path="../part14/">
            
                <a href="../part14/">
            
                    
                    Go 语言结构体
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.16" data-path="../part15/">
            
                <a href="../part15/">
            
                    
                    Go 语言切片(Slice)
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.17" data-path="../part16/">
            
                <a href="../part16/">
            
                    
                    Go 语言范围(Range)
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.18" data-path="../part17/">
            
                <a href="../part17/">
            
                    
                    Go 语言Map(集合)
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.19" data-path="../part18/">
            
                <a href="../part18/">
            
                    
                    Go 语言递归函数
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.20" data-path="../part19/">
            
                <a href="../part19/">
            
                    
                    Go 语言类型转换
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.21" data-path="../part20/">
            
                <a href="../part20/">
            
                    
                    Go 语言接口
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.22" data-path="../part21/">
            
                <a href="../part21/">
            
                    
                    Go 错误处理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.23" data-path="../part22/">
            
                <a href="../part22/">
            
                    
                    Go 并发
            
                </a>
            

            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >Go 语言变量</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h1 id="go-&#x8BED;&#x8A00;&#x53D8;&#x91CF;">Go &#x8BED;&#x8A00;&#x53D8;&#x91CF;</h1>
<p>&#x53D8;&#x91CF;&#x6765;&#x6E90;&#x4E8E;&#x6570;&#x5B66;&#xFF0C;&#x662F;&#x8BA1;&#x7B97;&#x673A;&#x8BED;&#x8A00;&#x4E2D;&#x80FD;&#x50A8;&#x5B58;&#x8BA1;&#x7B97;&#x7ED3;&#x679C;&#x6216;&#x80FD;&#x8868;&#x793A;&#x503C;&#x62BD;&#x8C61;&#x6982;&#x5FF5;&#x3002;</p>
<p>&#x53D8;&#x91CF;&#x53EF;&#x4EE5;&#x901A;&#x8FC7;&#x53D8;&#x91CF;&#x540D;&#x8BBF;&#x95EE;&#x3002;</p>
<p>Go &#x8BED;&#x8A00;&#x53D8;&#x91CF;&#x540D;&#x7531;&#x5B57;&#x6BCD;&#x3001;&#x6570;&#x5B57;&#x3001;&#x4E0B;&#x5212;&#x7EBF;&#x7EC4;&#x6210;&#xFF0C;&#x5176;&#x4E2D;&#x9996;&#x4E2A;&#x5B57;&#x7B26;&#x4E0D;&#x80FD;&#x4E3A;&#x6570;&#x5B57;&#x3002;</p>
<p>&#x58F0;&#x660E;&#x53D8;&#x91CF;&#x7684;&#x4E00;&#x822C;&#x5F62;&#x5F0F;&#x662F;&#x4F7F;&#x7528; var &#x5173;&#x952E;&#x5B57;&#xFF1A;</p>
<pre><code class="lang-go"><span class="hljs-keyword">var</span> identifier <span class="hljs-keyword">type</span>
</code></pre>
<p>&#x53EF;&#x4EE5;&#x4E00;&#x6B21;&#x58F0;&#x660E;&#x591A;&#x4E2A;&#x53D8;&#x91CF;&#xFF1A;</p>
<pre><code class="lang-go"><span class="hljs-keyword">var</span> identifier1, identifier2 <span class="hljs-keyword">type</span>
</code></pre>
<p>&#x5B9E;&#x4F8B;&#xFF1A;</p>
<pre><code class="lang-go"><span class="hljs-keyword">package</span> main

<span class="hljs-keyword">import</span> <span class="hljs-string">&quot;fmt&quot;</span>

<span class="hljs-keyword">func</span> main() {
    <span class="hljs-keyword">var</span> a <span class="hljs-keyword">string</span> = <span class="hljs-string">&quot;Google&quot;</span>
    fmt.Println(a)

    <span class="hljs-keyword">var</span> b, c <span class="hljs-keyword">int</span> = <span class="hljs-number">1</span>, <span class="hljs-number">2</span>
    fmt.Println(b, c)
}
</code></pre>
<p>&#x4EE5;&#x4E0A;&#x5B9E;&#x4F8B;&#x8F93;&#x51FA;&#x7ED3;&#x679C;&#x4E3A;&#xFF1A;</p>
<pre><code class="lang-sh">Google
1 2
</code></pre>
<h3 id="&#x53D8;&#x91CF;&#x58F0;&#x660E;">&#x53D8;&#x91CF;&#x58F0;&#x660E;</h3>
<h4 id="&#x7B2C;&#x4E00;&#x79CD;&#xFF0C;&#x6307;&#x5B9A;&#x53D8;&#x91CF;&#x7C7B;&#x578B;&#xFF0C;&#x5982;&#x679C;&#x6CA1;&#x6709;&#x521D;&#x59CB;&#x5316;&#xFF0C;&#x5219;&#x53D8;&#x91CF;&#x9ED8;&#x8BA4;&#x4E3A;&#x96F6;&#x503C;&#x3002;">&#x7B2C;&#x4E00;&#x79CD;&#xFF0C;&#x6307;&#x5B9A;&#x53D8;&#x91CF;&#x7C7B;&#x578B;&#xFF0C;&#x5982;&#x679C;&#x6CA1;&#x6709;&#x521D;&#x59CB;&#x5316;&#xFF0C;&#x5219;&#x53D8;&#x91CF;&#x9ED8;&#x8BA4;&#x4E3A;&#x96F6;&#x503C;&#x3002;</h4>
<pre><code class="lang-go"><span class="hljs-keyword">var</span> v_name v_type
v_name = value
</code></pre>
<p>&#x96F6;&#x503C;&#x5C31;&#x662F;&#x53D8;&#x91CF;&#x6CA1;&#x6709;&#x505A;&#x521D;&#x59CB;&#x5316;&#x65F6;&#x7CFB;&#x7EDF;&#x9ED8;&#x8BA4;&#x8BBE;&#x7F6E;&#x7684;&#x503C;&#x3002;</p>
<p>&#x5B9E;&#x4F8B;&#xFF1A;</p>
<pre><code class="lang-go"><span class="hljs-keyword">package</span> main
<span class="hljs-keyword">import</span> <span class="hljs-string">&quot;fmt&quot;</span>
<span class="hljs-keyword">func</span> main() {

    <span class="hljs-comment">// &#x58F0;&#x660E;&#x4E00;&#x4E2A;&#x53D8;&#x91CF;&#x5E76;&#x521D;&#x59CB;&#x5316;</span>
    <span class="hljs-keyword">var</span> a = <span class="hljs-string">&quot;Google&quot;</span>
    fmt.Println(a)

    <span class="hljs-comment">// &#x6CA1;&#x6709;&#x521D;&#x59CB;&#x5316;&#x5C31;&#x4E3A;&#x96F6;&#x503C;</span>
    <span class="hljs-keyword">var</span> b <span class="hljs-keyword">int</span>
    fmt.Println(b)

    <span class="hljs-comment">// bool &#x96F6;&#x503C;&#x4E3A; false</span>
    <span class="hljs-keyword">var</span> c <span class="hljs-keyword">bool</span>
    fmt.Println(c)
}
</code></pre>
<p>&#x4EE5;&#x4E0A;&#x5B9E;&#x4F8B;&#x6267;&#x884C;&#x7ED3;&#x679C;&#x4E3A;&#xFF1A;</p>
<pre><code class="lang-sh">Google
0
<span class="hljs-literal">false</span>
</code></pre>
<ul>
<li><p>&#x6570;&#x503C;&#x7C7B;&#x578B;&#xFF08;&#x5305;&#x62EC;complex64/128&#xFF09;&#x4E3A; <code>0</code></p>
</li>
<li><p>&#x5E03;&#x5C14;&#x7C7B;&#x578B;&#x4E3A; <strong><code>false</code></strong></p>
</li>
<li><p>&#x5B57;&#x7B26;&#x4E32;&#x4E3A; <code>&quot;&quot;&#xFF08;&#x7A7A;&#x5B57;&#x7B26;&#x4E32;&#xFF09;</code></p>
</li>
<li><p>&#x4EE5;&#x4E0B;&#x51E0;&#x79CD;&#x7C7B;&#x578B;&#x4E3A; <code>nil</code>&#xFF1A;</p>
<pre><code class="lang-go">  <span class="hljs-keyword">var</span> a *<span class="hljs-keyword">int</span>
  <span class="hljs-keyword">var</span> a []<span class="hljs-keyword">int</span>
  <span class="hljs-keyword">var</span> a <span class="hljs-keyword">map</span>[<span class="hljs-keyword">string</span>] <span class="hljs-keyword">int</span>
  <span class="hljs-keyword">var</span> a <span class="hljs-keyword">chan</span> <span class="hljs-keyword">int</span>
  <span class="hljs-keyword">var</span> a <span class="hljs-keyword">func</span>(<span class="hljs-keyword">string</span>) <span class="hljs-keyword">int</span>
  <span class="hljs-keyword">var</span> a error <span class="hljs-comment">// error &#x662F;&#x63A5;&#x53E3;</span>
</code></pre>
</li>
</ul>
<p>&#x5B9E;&#x4F8B;&#xFF1A;</p>
<pre><code class="lang-go"><span class="hljs-keyword">package</span> main

<span class="hljs-keyword">import</span> <span class="hljs-string">&quot;fmt&quot;</span>

<span class="hljs-keyword">func</span> main() {
    <span class="hljs-keyword">var</span> i <span class="hljs-keyword">int</span>
    <span class="hljs-keyword">var</span> f <span class="hljs-keyword">float64</span>
    <span class="hljs-keyword">var</span> b <span class="hljs-keyword">bool</span>
    <span class="hljs-keyword">var</span> s <span class="hljs-keyword">string</span>
    fmt.Printf(<span class="hljs-string">&quot;%v %v %v %q\n&quot;</span>, i, f, b, s)
}
</code></pre>
<p>&#x8F93;&#x51FA;&#x7ED3;&#x679C;&#x662F;&#xFF1A;</p>
<pre><code class="lang-sh">0 0 <span class="hljs-literal">false</span> <span class="hljs-string">&quot;&quot;</span>
</code></pre>
<h4 id="&#x7B2C;&#x4E8C;&#x79CD;&#xFF0C;&#x6839;&#x636E;&#x503C;&#x81EA;&#x884C;&#x5224;&#x5B9A;&#x53D8;&#x91CF;&#x7C7B;&#x578B;&#x3002;">&#x7B2C;&#x4E8C;&#x79CD;&#xFF0C;&#x6839;&#x636E;&#x503C;&#x81EA;&#x884C;&#x5224;&#x5B9A;&#x53D8;&#x91CF;&#x7C7B;&#x578B;&#x3002;</h4>
<pre><code class="lang-go"><span class="hljs-keyword">var</span> v_name = value
</code></pre>
<p>&#x5B9E;&#x4F8B;&#xFF1A;</p>
<pre><code class="lang-go"><span class="hljs-keyword">package</span> main

<span class="hljs-keyword">import</span> <span class="hljs-string">&quot;fmt&quot;</span>

<span class="hljs-keyword">func</span> main() {
    <span class="hljs-keyword">var</span> d = <span class="hljs-literal">true</span>
    fmt.Println(d)
}
</code></pre>
<p>&#x8F93;&#x51FA;&#x7ED3;&#x679C;&#x662F;&#xFF1A;</p>
<pre><code class="lang-sh"><span class="hljs-literal">true</span>
</code></pre>
<h4 id="&#x7B2C;&#x4E09;&#x79CD;&#xFF0C;&#x7701;&#x7565;-var-&#x6CE8;&#x610F;--&#x5DE6;&#x4FA7;&#x5982;&#x679C;&#x6CA1;&#x6709;&#x58F0;&#x660E;&#x65B0;&#x7684;&#x53D8;&#x91CF;&#xFF0C;&#x5C31;&#x4EA7;&#x751F;&#x7F16;&#x8BD1;&#x9519;&#x8BEF;&#xFF0C;&#x683C;&#x5F0F;&#xFF1A;">&#x7B2C;&#x4E09;&#x79CD;&#xFF0C;&#x7701;&#x7565; <code>var</code>, &#x6CE8;&#x610F; <code>:=</code> &#x5DE6;&#x4FA7;&#x5982;&#x679C;&#x6CA1;&#x6709;&#x58F0;&#x660E;&#x65B0;&#x7684;&#x53D8;&#x91CF;&#xFF0C;&#x5C31;&#x4EA7;&#x751F;&#x7F16;&#x8BD1;&#x9519;&#x8BEF;&#xFF0C;&#x683C;&#x5F0F;&#xFF1A;</h4>
<pre><code class="lang-go">v_name := value
</code></pre>
<p>&#x4F8B;&#x5982;</p>
<pre><code class="lang-go"><span class="hljs-keyword">var</span> intVal <span class="hljs-keyword">int</span> 

intVal :=<span class="hljs-number">1</span> <span class="hljs-comment">// &#x8FD9;&#x65F6;&#x5019;&#x4F1A;&#x4EA7;&#x751F;&#x7F16;&#x8BD1;&#x9519;&#x8BEF;</span>

intVal, intVal1 := <span class="hljs-number">1</span>, <span class="hljs-number">2</span> <span class="hljs-comment">// &#x6B64;&#x65F6;&#x4E0D;&#x4F1A;&#x4EA7;&#x751F;&#x7F16;&#x8BD1;&#x9519;&#x8BEF;&#xFF0C;&#x56E0;&#x4E3A;&#x6709;&#x58F0;&#x660E;&#x65B0;&#x7684;&#x53D8;&#x91CF;&#xFF0C;&#x56E0;&#x4E3A; := &#x662F;&#x4E00;&#x4E2A;&#x58F0;&#x660E;&#x8BED;&#x53E5;</span>
</code></pre>
<p>&#x53EF;&#x4EE5;&#x5C06; <code>var f string = &quot;Google&quot;</code> &#x7B80;&#x5199;&#x4E3A; <code>f := &quot;Google&quot;</code>&#xFF1A;
&#x5B9E;&#x4F8B;&#xFF1A;</p>
<pre><code class="lang-go"><span class="hljs-keyword">package</span> main

<span class="hljs-keyword">import</span> <span class="hljs-string">&quot;fmt&quot;</span>

<span class="hljs-keyword">func</span> main() {
    f := <span class="hljs-string">&quot;Google&quot;</span> <span class="hljs-comment">// var f string = &quot;Google&quot;</span>
    fmt.Println(f)
}
</code></pre>
<p>&#x8F93;&#x51FA;&#x7ED3;&#x679C;&#x662F;&#xFF1A;</p>
<pre><code class="lang-sh">Google
</code></pre>
<h3 id="&#x591A;&#x53D8;&#x91CF;&#x58F0;&#x660E;">&#x591A;&#x53D8;&#x91CF;&#x58F0;&#x660E;</h3>
<pre><code class="lang-go"><span class="hljs-comment">//&#x7C7B;&#x578B;&#x76F8;&#x540C;&#x591A;&#x4E2A;&#x53D8;&#x91CF;, &#x975E;&#x5168;&#x5C40;&#x53D8;&#x91CF;</span>
<span class="hljs-keyword">var</span> vname1, vname2, vname3 <span class="hljs-keyword">type</span>
vname1, vname2, vname3 = v1, v2, v3

<span class="hljs-keyword">var</span> vname1, vname2, vname3 = v1, v2, v3 <span class="hljs-comment">// &#x548C; python &#x5F88;&#x50CF;,&#x4E0D;&#x9700;&#x8981;&#x663E;&#x793A;&#x58F0;&#x660E;&#x7C7B;&#x578B;&#xFF0C;&#x81EA;&#x52A8;&#x63A8;&#x65AD;</span>

vname1, vname2, vname3 := v1, v2, v3 <span class="hljs-comment">// &#x51FA;&#x73B0;&#x5728; := &#x5DE6;&#x4FA7;&#x7684;&#x53D8;&#x91CF;&#x4E0D;&#x5E94;&#x8BE5;&#x662F;&#x5DF2;&#x7ECF;&#x88AB;&#x58F0;&#x660E;&#x8FC7;&#x7684;&#xFF0C;&#x5426;&#x5219;&#x4F1A;&#x5BFC;&#x81F4;&#x7F16;&#x8BD1;&#x9519;&#x8BEF;</span>

<span class="hljs-comment">// &#x8FD9;&#x79CD;&#x56E0;&#x5F0F;&#x5206;&#x89E3;&#x5173;&#x952E;&#x5B57;&#x7684;&#x5199;&#x6CD5;&#x4E00;&#x822C;&#x7528;&#x4E8E;&#x58F0;&#x660E;&#x5168;&#x5C40;&#x53D8;&#x91CF;</span>
<span class="hljs-keyword">var</span> (
    vname1 v_type1
    vname2 v_type2
)
</code></pre>
<p>&#x5B9E;&#x4F8B;&#xFF1A;</p>
<pre><code class="lang-go"><span class="hljs-keyword">package</span> main

<span class="hljs-keyword">var</span> x, y <span class="hljs-keyword">int</span>
<span class="hljs-keyword">var</span> (  <span class="hljs-comment">// &#x8FD9;&#x79CD;&#x56E0;&#x5F0F;&#x5206;&#x89E3;&#x5173;&#x952E;&#x5B57;&#x7684;&#x5199;&#x6CD5;&#x4E00;&#x822C;&#x7528;&#x4E8E;&#x58F0;&#x660E;&#x5168;&#x5C40;&#x53D8;&#x91CF;</span>
    a <span class="hljs-keyword">int</span>
    b <span class="hljs-keyword">bool</span>
)

<span class="hljs-keyword">var</span> c, d <span class="hljs-keyword">int</span> = <span class="hljs-number">1</span>, <span class="hljs-number">2</span>
<span class="hljs-keyword">var</span> e, f = <span class="hljs-number">123</span>, <span class="hljs-string">&quot;hello&quot;</span>

<span class="hljs-comment">//&#x8FD9;&#x79CD;&#x4E0D;&#x5E26;&#x58F0;&#x660E;&#x683C;&#x5F0F;&#x7684;&#x53EA;&#x80FD;&#x5728;&#x51FD;&#x6570;&#x4F53;&#x4E2D;&#x51FA;&#x73B0;</span>
<span class="hljs-comment">//g, h := 123, &quot;hello&quot;</span>

<span class="hljs-keyword">func</span> main(){
    g, h := <span class="hljs-number">123</span>, <span class="hljs-string">&quot;hello&quot;</span>
    <span class="hljs-built_in">println</span>(x, y, a, b, c, d, e, f, g, h)
}
</code></pre>
<p>&#x4EE5;&#x4E0A;&#x5B9E;&#x4F8B;&#x6267;&#x884C;&#x7ED3;&#x679C;&#x4E3A;&#xFF1A;</p>
<pre><code class="lang-sh">0 0 0 <span class="hljs-literal">false</span> 1 2 123 hello 123 hello
</code></pre>
<hr>
<h2 id="&#x503C;&#x7C7B;&#x578B;&#x548C;&#x5F15;&#x7528;&#x7C7B;&#x578B;">&#x503C;&#x7C7B;&#x578B;&#x548C;&#x5F15;&#x7528;&#x7C7B;&#x578B;</h2>
<p>&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#x6240;&#x6709;&#x50CF; <code>int</code>&#x3001;<code>float</code>&#x3001;<code>bool</code> &#x548C; <code>string</code> &#x8FD9;&#x4E9B;&#x57FA;&#x672C;&#x7C7B;&#x578B;&#x90FD;&#x5C5E;&#x4E8E;&#x503C;&#x7C7B;&#x578B;&#xFF0C;&#x4F7F;&#x7528;&#x8FD9;&#x4E9B;&#x7C7B;&#x578B;&#x7684;&#x53D8;&#x91CF;&#x76F4;&#x63A5;&#x6307;&#x5411;&#x5B58;&#x5728;&#x5185;&#x5B58;&#x4E2D;&#x7684;&#x503C;&#xFF1A;</p>
<center>
    <img style="border-radius: 0.3125em;
    box-shadow: 0 2px 4px 0 rgba(34,36,38,.12),0 2px 10px 0 rgba(34,36,38,.08);" src="../source/images/part6/01.png">
    <br>
    <div style="color:orange; border-bottom: 0px solid #d9d9d9;
    display: inline-block;
    color: #999;ds
    padding: 5px;"></div>
</center>

<p>&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#x5F53;&#x4F7F;&#x7528;&#x7B49;&#x53F7; = &#x5C06;&#x4E00;&#x4E2A;&#x53D8;&#x91CF;&#x7684;&#x503C;&#x8D4B;&#x503C;&#x7ED9;&#x53E6;&#x4E00;&#x4E2A;&#x53D8;&#x91CF;&#x65F6;&#xFF0C;&#x5982;&#xFF1A;<code>j = i</code>&#xFF0C;&#x5B9E;&#x9645;&#x4E0A;&#x662F;&#x5728;&#x5185;&#x5B58;&#x4E2D;&#x5C06; <code>i</code> &#x7684;&#x503C;&#x8FDB;&#x884C;&#x4E86;&#x62F7;&#x8D1D;&#xFF1A;</p>
<center>
    <img style="border-radius: 0.3125em;
    box-shadow: 0 2px 4px 0 rgba(34,36,38,.12),0 2px 10px 0 rgba(34,36,38,.08);" src="../source/images/part6/02.png">
    <br>
    <div style="color:orange; border-bottom: 0px solid #d9d9d9;
    display: inline-block;
    color: #999;ds
    padding: 5px;"></div>
</center>

<p>&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#x4F60;&#x53EF;&#x4EE5;&#x901A;&#x8FC7; <code>&amp;i</code> &#x6765;&#x83B7;&#x53D6;&#x53D8;&#x91CF; <code>i</code> &#x7684;&#x5185;&#x5B58;&#x5730;&#x5740;&#xFF0C;&#x4F8B;&#x5982;&#xFF1A;<code>0xf840000040&#xFF08;&#x6BCF;&#x6B21;&#x7684;&#x5730;&#x5740;&#x90FD;&#x53EF;&#x80FD;&#x4E0D;&#x4E00;&#x6837;&#xFF09;</code>&#x3002;&#x503C;&#x7C7B;&#x578B;&#x7684;&#x53D8;&#x91CF;&#x7684;&#x503C;&#x5B58;&#x50A8;&#x5728;&#x6808;&#x4E2D;&#x3002;</p>
<p>&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#x5185;&#x5B58;&#x5730;&#x5740;&#x4F1A;&#x6839;&#x636E;&#x673A;&#x5668;&#x7684;&#x4E0D;&#x540C;&#x800C;&#x6709;&#x6240;&#x4E0D;&#x540C;&#xFF0C;&#x751A;&#x81F3;&#x76F8;&#x540C;&#x7684;&#x7A0B;&#x5E8F;&#x5728;&#x4E0D;&#x540C;&#x7684;&#x673A;&#x5668;&#x4E0A;&#x6267;&#x884C;&#x540E;&#x4E5F;&#x4F1A;&#x6709;&#x4E0D;&#x540C;&#x7684;&#x5185;&#x5B58;&#x5730;&#x5740;&#x3002;&#x56E0;&#x4E3A;&#x6BCF;&#x53F0;&#x673A;&#x5668;&#x53EF;&#x80FD;&#x6709;&#x4E0D;&#x540C;&#x7684;&#x5B58;&#x50A8;&#x5668;&#x5E03;&#x5C40;&#xFF0C;&#x5E76;&#x4E14;&#x4F4D;&#x7F6E;&#x5206;&#x914D;&#x4E5F;&#x53EF;&#x80FD;&#x4E0D;&#x540C;&#x3002;</p>
<p>&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#x66F4;&#x590D;&#x6742;&#x7684;&#x6570;&#x636E;&#x901A;&#x5E38;&#x4F1A;&#x9700;&#x8981;&#x4F7F;&#x7528;&#x591A;&#x4E2A;&#x5B57;&#xFF0C;&#x8FD9;&#x4E9B;&#x6570;&#x636E;&#x4E00;&#x822C;&#x4F7F;&#x7528;&#x5F15;&#x7528;&#x7C7B;&#x578B;&#x4FDD;&#x5B58;&#x3002;</p>
<p>&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#x4E00;&#x4E2A;&#x5F15;&#x7528;&#x7C7B;&#x578B;&#x7684;&#x53D8;&#x91CF; <code>r1</code> &#x5B58;&#x50A8;&#x7684;&#x662F; <code>r1</code> &#x7684;&#x503C;&#x6240;&#x5728;&#x7684;&#x5185;&#x5B58;&#x5730;&#x5740;&#xFF08;&#x6570;&#x5B57;&#xFF09;&#xFF0C;&#x6216;&#x5185;&#x5B58;&#x5730;&#x5740;&#x4E2D;&#x7B2C;&#x4E00;&#x4E2A;&#x5B57;&#x6240;&#x5728;&#x7684;&#x4F4D;&#x7F6E;&#x3002;</p>
<center>
    <img style="border-radius: 0.3125em;
    box-shadow: 0 2px 4px 0 rgba(34,36,38,.12),0 2px 10px 0 rgba(34,36,38,.08);" src="../source/images/part6/03.png">
    <br>
    <div style="color:orange; border-bottom: 0px solid #d9d9d9;
    display: inline-block;
    color: #999;ds
    padding: 5px;"></div>
</center>

<p>&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#x8FD9;&#x4E2A;&#x5185;&#x5B58;&#x5730;&#x5740;&#x79F0;&#x4E4B;&#x4E3A;&#x6307;&#x9488;&#xFF0C;&#x8FD9;&#x4E2A;&#x6307;&#x9488;&#x5B9E;&#x9645;&#x4E0A;&#x4E5F;&#x88AB;&#x5B58;&#x5728;&#x53E6;&#x5916;&#x7684;&#x67D0;&#x4E00;&#x4E2A;&#x503C;&#x4E2D;&#x3002;</p>
<p>&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#x540C;&#x4E00;&#x4E2A;&#x5F15;&#x7528;&#x7C7B;&#x578B;&#x7684;&#x6307;&#x9488;&#x6307;&#x5411;&#x7684;&#x591A;&#x4E2A;&#x5B57;&#x53EF;&#x4EE5;&#x662F;&#x5728;&#x8FDE;&#x7EED;&#x7684;&#x5185;&#x5B58;&#x5730;&#x5740;&#x4E2D;&#xFF08;&#x5185;&#x5B58;&#x5E03;&#x5C40;&#x662F;&#x8FDE;&#x7EED;&#x7684;&#xFF09;&#xFF0C;&#x8FD9;&#x4E5F;&#x662F;&#x8BA1;&#x7B97;&#x6548;&#x7387;&#x6700;&#x9AD8;&#x7684;&#x4E00;&#x79CD;&#x5B58;&#x50A8;&#x5F62;&#x5F0F;&#xFF1B;&#x4E5F;&#x53EF;&#x4EE5;&#x5C06;&#x8FD9;&#x4E9B;&#x5B57;&#x5206;&#x6563;&#x5B58;&#x653E;&#x5728;&#x5185;&#x5B58;&#x4E2D;&#xFF0C;&#x6BCF;&#x4E2A;&#x5B57;&#x90FD;&#x6307;&#x793A;&#x4E86;&#x4E0B;&#x4E00;&#x4E2A;&#x5B57;&#x6240;&#x5728;&#x7684;&#x5185;&#x5B58;&#x5730;&#x5740;&#x3002;</p>
<p>&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#x5F53;&#x4F7F;&#x7528;&#x8D4B;&#x503C;&#x8BED;&#x53E5; <code>r2 = r1</code> &#x65F6;&#xFF0C;&#x53EA;&#x6709;&#x5F15;&#x7528;&#xFF08;&#x5730;&#x5740;&#xFF09;&#x88AB;&#x590D;&#x5236;&#x3002;</p>
<p>&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#x5982;&#x679C; <code>r1</code> &#x7684;&#x503C;&#x88AB;&#x6539;&#x53D8;&#x4E86;&#xFF0C;&#x90A3;&#x4E48;&#x8FD9;&#x4E2A;&#x503C;&#x7684;&#x6240;&#x6709;&#x5F15;&#x7528;&#x90FD;&#x4F1A;&#x6307;&#x5411;&#x88AB;&#x4FEE;&#x6539;&#x540E;&#x7684;&#x5185;&#x5BB9;&#xFF0C;&#x5728;&#x8FD9;&#x4E2A;&#x4F8B;&#x5B50;&#x4E2D;&#xFF0C;<code>r2</code> &#x4E5F;&#x4F1A;&#x53D7;&#x5230;&#x5F71;&#x54CD;&#x3002;</p>
<hr>
<h2 id="&#x7B80;&#x77ED;&#x5F62;&#x5F0F;&#xFF0C;&#x4F7F;&#x7528;--&#x8D4B;&#x503C;&#x64CD;&#x4F5C;&#x7B26;">&#x7B80;&#x77ED;&#x5F62;&#x5F0F;&#xFF0C;&#x4F7F;&#x7528; := &#x8D4B;&#x503C;&#x64CD;&#x4F5C;&#x7B26;</h2>
<p>&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#x6211;&#x4EEC;&#x77E5;&#x9053;&#x53EF;&#x4EE5;&#x5728;&#x53D8;&#x91CF;&#x7684;&#x521D;&#x59CB;&#x5316;&#x65F6;&#x7701;&#x7565;&#x53D8;&#x91CF;&#x7684;&#x7C7B;&#x578B;&#x800C;&#x7531;&#x7CFB;&#x7EDF;&#x81EA;&#x52A8;&#x63A8;&#x65AD;&#xFF0C;&#x58F0;&#x660E;&#x8BED;&#x53E5;&#x5199;&#x4E0A; var &#x5173;&#x952E;&#x5B57;&#x5176;&#x5B9E;&#x662F;&#x663E;&#x5F97;&#x6709;&#x4E9B;&#x591A;&#x4F59;&#x4E86;&#xFF0C;&#x56E0;&#x6B64;&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x5C06;&#x5B83;&#x4EEC;&#x7B80;&#x5199;&#x4E3A; <code>a := 50</code> &#x6216; <code>b := false</code>&#x3002;</p>
<p>&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;<code>a</code> &#x548C; <code>b</code> &#x7684;&#x7C7B;&#x578B;&#xFF08;<code>int</code> &#x548C; <code>bool</code>&#xFF09;&#x5C06;&#x7531;&#x7F16;&#x8BD1;&#x5668;&#x81EA;&#x52A8;&#x63A8;&#x65AD;&#x3002;</p>
<p>&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#x8FD9;&#x662F;&#x4F7F;&#x7528;&#x53D8;&#x91CF;&#x7684;&#x9996;&#x9009;&#x5F62;&#x5F0F;&#xFF0C;&#x4F46;&#x662F;&#x5B83;&#x53EA;&#x80FD;&#x88AB;&#x7528;&#x5728;&#x51FD;&#x6570;&#x4F53;&#x5185;&#xFF0C;&#x800C;&#x4E0D;&#x53EF;&#x4EE5;&#x7528;&#x4E8E;&#x5168;&#x5C40;&#x53D8;&#x91CF;&#x7684;&#x58F0;&#x660E;&#x4E0E;&#x8D4B;&#x503C;&#x3002;&#x4F7F;&#x7528;&#x64CD;&#x4F5C;&#x7B26; <code>:=</code> &#x53EF;&#x4EE5;&#x9AD8;&#x6548;&#x5730;&#x521B;&#x5EFA;&#x4E00;&#x4E2A;&#x65B0;&#x7684;&#x53D8;&#x91CF;&#xFF0C;&#x79F0;&#x4E4B;&#x4E3A;&#x521D;&#x59CB;&#x5316;&#x58F0;&#x660E;&#x3002;</p>
<h3 id="&#x6CE8;&#x610F;&#x4E8B;&#x9879;">&#x6CE8;&#x610F;&#x4E8B;&#x9879;</h3>
<p>&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#x5982;&#x679C;&#x5728;&#x76F8;&#x540C;&#x7684;&#x4EE3;&#x7801;&#x5757;&#x4E2D;&#xFF0C;&#x6211;&#x4EEC;&#x4E0D;&#x53EF;&#x4EE5;&#x518D;&#x6B21;&#x5BF9;&#x4E8E;&#x76F8;&#x540C;&#x540D;&#x79F0;&#x7684;&#x53D8;&#x91CF;&#x4F7F;&#x7528;&#x521D;&#x59CB;&#x5316;&#x58F0;&#x660E;&#xFF0C;&#x4F8B;&#x5982;&#xFF1A;<code>a := 20</code> &#x5C31;&#x662F;&#x4E0D;&#x88AB;&#x5141;&#x8BB8;&#x7684;&#xFF0C;&#x7F16;&#x8BD1;&#x5668;&#x4F1A;&#x63D0;&#x793A;&#x9519;&#x8BEF; <code>no new variables on left side of :=</code>&#xFF0C;&#x4F46;&#x662F; <code>a = 20</code> &#x662F;&#x53EF;&#x4EE5;&#x7684;&#xFF0C;&#x56E0;&#x4E3A;&#x8FD9;&#x662F;&#x7ED9;&#x76F8;&#x540C;&#x7684;&#x53D8;&#x91CF;&#x8D4B;&#x4E88;&#x4E00;&#x4E2A;&#x65B0;&#x7684;&#x503C;&#x3002;</p>
<p>&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#x5982;&#x679C;&#x4F60;&#x5728;&#x5B9A;&#x4E49;&#x53D8;&#x91CF; <code>a</code> &#x4E4B;&#x524D;&#x4F7F;&#x7528;&#x5B83;&#xFF0C;&#x5219;&#x4F1A;&#x5F97;&#x5230;&#x7F16;&#x8BD1;&#x9519;&#x8BEF; <code>undefined: a</code>&#x3002;</p>
<p>&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#x5982;&#x679C;&#x4F60;&#x58F0;&#x660E;&#x4E86;&#x4E00;&#x4E2A;&#x5C40;&#x90E8;&#x53D8;&#x91CF;&#x5374;&#x6CA1;&#x6709;&#x5728;&#x76F8;&#x540C;&#x7684;&#x4EE3;&#x7801;&#x5757;&#x4E2D;&#x4F7F;&#x7528;&#x5B83;&#xFF0C;&#x540C;&#x6837;&#x4F1A;&#x5F97;&#x5230;&#x7F16;&#x8BD1;&#x9519;&#x8BEF;&#xFF0C;&#x4F8B;&#x5982;&#x4E0B;&#x9762;&#x8FD9;&#x4E2A;&#x4F8B;&#x5B50;&#x5F53;&#x4E2D;&#x7684;&#x53D8;&#x91CF; <code>a</code>&#xFF1A;</p>
<p>&#x5B9E;&#x4F8B;&#xFF1A;</p>
<pre><code class="lang-go"><span class="hljs-keyword">package</span> main

<span class="hljs-keyword">import</span> <span class="hljs-string">&quot;fmt&quot;</span>

<span class="hljs-keyword">func</span> main() {
   <span class="hljs-keyword">var</span> a <span class="hljs-keyword">string</span> = <span class="hljs-string">&quot;abc&quot;</span>
   fmt.Println(<span class="hljs-string">&quot;hello, world&quot;</span>)
}
</code></pre>
<p>&#x5C1D;&#x8BD5;&#x7F16;&#x8BD1;&#x8FD9;&#x6BB5;&#x4EE3;&#x7801;&#x5C06;&#x5F97;&#x5230;&#x9519;&#x8BEF; <code>a declared and not used</code>&#x3002;</p>
<p>&#x6B64;&#x5916;&#xFF0C;&#x5355;&#x7EAF;&#x5730;&#x7ED9; <code>a</code> &#x8D4B;&#x503C;&#x4E5F;&#x662F;&#x4E0D;&#x591F;&#x7684;&#xFF0C;&#x8FD9;&#x4E2A;&#x503C;&#x5FC5;&#x987B;&#x88AB;&#x4F7F;&#x7528;&#xFF0C;&#x6240;&#x4EE5;&#x4F7F;&#x7528;</p>
<pre><code class="lang-go"><span class="hljs-keyword">var</span> a, b, c <span class="hljs-keyword">int</span>
</code></pre>
<p>&#x591A;&#x53D8;&#x91CF;&#x53EF;&#x4EE5;&#x5728;&#x540C;&#x4E00;&#x884C;&#x8FDB;&#x884C;&#x8D4B;&#x503C;&#xFF0C;&#x5982;&#xFF1A;</p>
<pre><code class="lang-go"><span class="hljs-keyword">var</span> a, b <span class="hljs-keyword">int</span>
<span class="hljs-keyword">var</span> c <span class="hljs-keyword">string</span>
a, b, c = <span class="hljs-number">5</span>, <span class="hljs-number">7</span>, <span class="hljs-string">&quot;abc&quot;</span>
</code></pre>
<p>&#x4E0A;&#x9762;&#x8FD9;&#x884C;&#x5047;&#x8BBE;&#x4E86;&#x53D8;&#x91CF; a&#xFF0C;b &#x548C; c &#x90FD;&#x5DF2;&#x7ECF;&#x88AB;&#x58F0;&#x660E;&#xFF0C;&#x5426;&#x5219;&#x7684;&#x8BDD;&#x5E94;&#x8BE5;&#x8FD9;&#x6837;&#x4F7F;&#x7528;&#xFF1A;</p>
<pre><code class="lang-go">a, b, c := <span class="hljs-number">5</span>, <span class="hljs-number">7</span>, <span class="hljs-string">&quot;abc&quot;</span>
</code></pre>
<p>&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#x53F3;&#x8FB9;&#x7684;&#x8FD9;&#x4E9B;&#x503C;&#x4EE5;&#x76F8;&#x540C;&#x7684;&#x987A;&#x5E8F;&#x8D4B;&#x503C;&#x7ED9;&#x5DE6;&#x8FB9;&#x7684;&#x53D8;&#x91CF;&#xFF0C;&#x6240;&#x4EE5; <code>a</code> &#x7684;&#x503C;&#x662F; <code>5</code>&#xFF0C; <code>b</code> &#x7684;&#x503C;&#x662F; <code>7</code>&#xFF0C;<code>c</code> &#x7684;&#x503C;&#x662F; <code>&quot;abc&quot;</code>&#x3002;</p>
<p>&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#x8FD9;&#x88AB;&#x79F0;&#x4E3A; <strong>&#x5E76;&#x884C;</strong> &#x6216; <strong>&#x540C;&#x65F6;</strong> &#x8D4B;&#x503C;&#x3002;</p>
<p>&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#x5982;&#x679C;&#x4F60;&#x60F3;&#x8981;&#x4EA4;&#x6362;&#x4E24;&#x4E2A;&#x53D8;&#x91CF;&#x7684;&#x503C;&#xFF0C;&#x5219;&#x53EF;&#x4EE5;&#x7B80;&#x5355;&#x5730;&#x4F7F;&#x7528; <code>a, b = b, a</code>&#xFF0C;&#x4E24;&#x4E2A;&#x53D8;&#x91CF;&#x7684;&#x7C7B;&#x578B;&#x5FC5;&#x987B;&#x662F;&#x76F8;&#x540C;&#x3002;</p>
<p>&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#x7A7A;&#x767D;&#x6807;&#x8BC6;&#x7B26; <code>_</code> &#x4E5F;&#x88AB;&#x7528;&#x4E8E;&#x629B;&#x5F03;&#x503C;&#xFF0C;&#x5982;&#x503C; <code>5</code> &#x5728;&#xFF1A;<code>_, b = 5, 7</code> &#x4E2D;&#x88AB;&#x629B;&#x5F03;&#x3002;</p>
<p>&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;<code>_</code> &#x5B9E;&#x9645;&#x4E0A;&#x662F;&#x4E00;&#x4E2A;&#x53EA;&#x5199;&#x53D8;&#x91CF;&#xFF0C;&#x4F60;&#x4E0D;&#x80FD;&#x5F97;&#x5230;&#x5B83;&#x7684;&#x503C;&#x3002;&#x8FD9;&#x6837;&#x505A;&#x662F;&#x56E0;&#x4E3A; Go &#x8BED;&#x8A00;&#x4E2D;&#x4F60;&#x5FC5;&#x987B;&#x4F7F;&#x7528;&#x6240;&#x6709;&#x88AB;&#x58F0;&#x660E;&#x7684;&#x53D8;&#x91CF;&#xFF0C;&#x4F46;&#x6709;&#x65F6;&#x4F60;&#x5E76;&#x4E0D;&#x9700;&#x8981;&#x4F7F;&#x7528;&#x4ECE;&#x4E00;&#x4E2A;&#x51FD;&#x6570;&#x5F97;&#x5230;&#x7684;&#x6240;&#x6709;&#x8FD4;&#x56DE;&#x503C;&#x3002;</p>
<p>&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#x5E76;&#x884C;&#x8D4B;&#x503C;&#x4E5F;&#x88AB;&#x7528;&#x4E8E;&#x5F53;&#x4E00;&#x4E2A;&#x51FD;&#x6570;&#x8FD4;&#x56DE;&#x591A;&#x4E2A;&#x8FD4;&#x56DE;&#x503C;&#x65F6;&#xFF0C;&#x6BD4;&#x5982;&#x8FD9;&#x91CC;&#x7684; <code>val</code> &#x548C;&#x9519;&#x8BEF; <code>err</code> &#x662F;&#x901A;&#x8FC7;&#x8C03;&#x7528; <code>Func1</code> &#x51FD;&#x6570;&#x540C;&#x65F6;&#x5F97;&#x5230;&#xFF1A;<code>val, err = Func1(var1)</code>&#x3002;</p>
<hr>
<h2 id="ps">PS</h2>
<p>&#x7A7A;&#x767D;&#x6807;&#x8BC6;&#x7B26;&#x5728;&#x51FD;&#x6570;&#x8FD4;&#x56DE;&#x503C;&#x65F6;&#x7684;&#x4F7F;&#x7528;&#xFF1A;</p>
<pre><code class="lang-go"><span class="hljs-keyword">package</span> main

<span class="hljs-keyword">import</span> <span class="hljs-string">&quot;fmt&quot;</span>

<span class="hljs-keyword">func</span> main() {
  _, numb, strs := numbers() <span class="hljs-comment">//&#x53EA;&#x83B7;&#x53D6;&#x51FD;&#x6570;&#x8FD4;&#x56DE;&#x503C;&#x7684;&#x540E;&#x4E24;&#x4E2A;</span>
  fmt.Println(numb, strs)
}

<span class="hljs-comment">//&#x4E00;&#x4E2A;&#x53EF;&#x4EE5;&#x8FD4;&#x56DE;&#x591A;&#x4E2A;&#x503C;&#x7684;&#x51FD;&#x6570;</span>
<span class="hljs-keyword">func</span> numbers()(<span class="hljs-keyword">int</span>, <span class="hljs-keyword">int</span>, <span class="hljs-keyword">string</span>){
  a , b , c := <span class="hljs-number">1</span> , <span class="hljs-number">2</span> , <span class="hljs-string">&quot;str&quot;</span>
  <span class="hljs-keyword">return</span> a, b, c
}
</code></pre>
<p>&#x8F93;&#x51FA;&#x7ED3;&#x679C;&#xFF1A;</p>
<pre><code class="lang-sh">2 str
</code></pre>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="../part5/" class="navigation navigation-prev " aria-label="Previous page: Go 语言数据类型">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="../part7/" class="navigation navigation-next " aria-label="Next page: Go 语言常量">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"Go 语言变量","level":"1.7","depth":1,"next":{"title":"Go 语言常量","level":"1.8","depth":1,"path":"part7/README.md","ref":"part7/README.md","articles":[]},"previous":{"title":"Go 语言数据类型","level":"1.6","depth":1,"path":"part5/README.md","ref":"part5/README.md","articles":[]},"dir":"ltr"},"config":{"gitbook":"*","theme":"default","variables":{},"plugins":[],"pluginsConfig":{"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"}},"file":{"path":"part6/README.md","mtime":"2021-01-19T11:30:22.587Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2021-01-21T06:29:04.898Z"},"basePath":"..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../gitbook/gitbook.js"></script>
    <script src="../gitbook/theme.js"></script>
    
        
        <script src="../gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

